Skip to content

fix(transcript): fold mid-turn task notifications into the current turn on cold rebuild - #3102

Merged
wbxl2000 merged 32 commits into
mainfrom
fix/transcript-notification-fold
Aug 24, 2026
Merged

fix(transcript): fold mid-turn task notifications into the current turn on cold rebuild#3102
wbxl2000 merged 32 commits into
mainfrom
fix/transcript-notification-fold

Conversation

@wbxl2000

Copy link
Copy Markdown
Collaborator

Found by the main-flow shadow reconciliation (kimi-code-app#279): a background-task completion notice that arrives mid-turn is persisted as a task-origin user message, and the cold rebuild (groupMessagesIntoSnapshot) opened a NEW turn for each one — splitting the logical turn and reordering user/assistant chat turns, while the live projector folds them into the open step as role:'user' text frames.

Now the cold path matches the live path: a task/background_task/task_notification user message whose previous message is assistant/tool output folds into the current turn as a taskId-keyed user text frame; otherwise (idle — the engine really does open a task turn) it keeps opening its own turn, preserving the legacy behavior locked by the existing test.

Tests: new cold-path case (notification between assistant messages folds in, one turn, taskId kept) + the existing legacy-behavior case both green; transcript package 79 green, typecheck/lint/no-comments clean.

@pkg-pr-new

pkg-pr-new Bot commented Aug 19, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@9d7120f
npx https://pkg.pr.new/@moonshot-ai/kimi-code@9d7120f

commit: 9d7120f

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 71c345b4c4

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/transcript/src/history/groupTurns.ts Outdated
@changeset-bot

changeset-bot Bot commented Aug 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9d7120f

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 30a206bd4d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/transcript/src/history/groupTurns.ts Outdated
@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ae00fdd883

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/transcript/src/history/groupTurns.ts Outdated
@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 709ca5b0d3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/transcript/src/history/groupTurns.ts Outdated
Comment thread packages/kap-server/src/services/transcript/transcriptService.ts
@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 18330dae81

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/transcript/src/history/groupTurns.ts Outdated
@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b906a560da

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/transcript/src/history/groupTurns.ts Outdated
Comment thread packages/transcript/src/history/groupTurns.ts Outdated
Comment thread packages/transcript/src/history/groupTurns.ts Outdated
@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1ca99dae34

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/transcript/src/history/groupTurns.ts Outdated
Comment thread packages/transcript/src/history/groupTurns.ts Outdated
@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a211b70fe2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/kap-server/src/services/transcript/coreEventMap.ts Outdated
@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 85caf6d59f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/kap-server/src/services/transcript/transcriptService.ts Outdated
@wbxl2000
wbxl2000 force-pushed the fix/transcript-notification-fold branch from 74bb90e to bc9a862 Compare August 20, 2026 11:07
@wbxl2000
wbxl2000 force-pushed the fix/transcript-notification-fold branch from bc9a862 to 11f9cd0 Compare August 20, 2026 18:47
@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2f795ccac7

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/transcript/src/model/task.ts
Comment thread packages/kap-server/src/services/transcript/coreEventMap.ts
Comment thread packages/kap-server/src/services/transcript/coreEventMap.ts Outdated
…prompt content on accepted, normalize queued content

- transcriptTaskSchema declares model/thinkingEffort: Zod strips
  undeclared keys, so schema-driven REST/WS consumers lost both fields
  the projector now populates.
- PromptAccepted carries the admitted content (it is the only event a
  first-turn prompt ever emits, and the bare id left the prompts entity
  permanently partial) — projected with userMessageId and the public
  content shape via projectPromptContentParts, same as queued and the
  live backfill.
- Regenerate the wire manifest and re-record the affected event-stream
  snapshots.
@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b72f0fba5f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/kap-server/src/services/transcript/coreEventMap.ts
Comment thread packages/kap-server/src/services/transcript/coreEventMap.ts Outdated
…cepted prompt details across queueing

- onTaskLifecycle carried resultSummary/usage/error/stateReason but
  dropped model/thinkingEffort: a completed detached-Agent row lost the
  metadata spawned set while running.
- prompt.queued rebuilt the entity from scratch, discarding the
  userMessageId and createdAt that prompt.accepted had just stamped —
  build the queued update from prev.
@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6c0cc98134

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/agent-core-v2/src/agent/prompt/promptOps.ts
The observable marker made the broadcaster forward every accepted
prompt to v1 WS clients, but events-zod has no accepted variant (v1
surfaces submission through the service-synthesized prompt.submitted)
and the SDK mapper didn't drop it — schema-driven clients could reject
the frame. Drop it at the WS edge and in the SDK's dropped set; the
transcript projection keeps consuming it internally.
@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fc52080934

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/kap-server/src/services/transcript/transcriptService.ts
@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 71a941a7ab

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/transcript/src/history/groupTurns.ts Outdated
@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9721d36d91

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread .changeset/transcript-notification-fold.md
@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1e123e5192

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/transcript/src/history/groupTurns.ts Outdated
@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 9d7120f545

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@wbxl2000
wbxl2000 merged commit 2f12469 into main Aug 24, 2026
15 checks passed
@wbxl2000
wbxl2000 deleted the fix/transcript-notification-fold branch August 24, 2026 06:33
lucasfelipe24 pushed a commit to lucasfelipe24/jarvis-code that referenced this pull request Aug 24, 2026
…rn on cold rebuild (MoonshotAI#3102)

* fix(transcript): fold mid-turn task notifications into the current turn on cold rebuild

* chore: changeset for the notification fold fix

* fix(transcript): key the notification fold on persisted task-turn boundaries, not the previous message role

* fix(transcript): collect background_task turn origins too, and fall back when the wire has no turn.started records

* fix(transcript): fold consecutive task notifications into the same turn

* fix(transcript): normalize folded notification text to the live title/body form

* fix(transcript): stop folded notification text before child blocks, preserve legacy background_task turns absent from the boundary set

* fix(transcript): truncate folded notification text at the first child-block tag, not just the tag lines

* fix(transcript): drop folded notifications without a persisted step, truncate only at output blocks

* fix(transcript): attach mid-turn task notifications to the following step, cold and live

* fix(transcript): keep other tasks' notifications in task-origin turns

* fix(transcript): derive task-turn boundaries from durable turn.prompt records

* feat(transcript): carry subagent model and thinking effort on task entities

* fix(transcript): mirror turn liveness into meta.activity, live and cold

* fix(transcript): populate the prompts entity from prompt.accepted/queued engine events

* fix(transcript): reconcile liveness and the prompt queue at backfill from the live loop state

* fix(transcript): include the prompts entity in the REST transcript response

* fix(agent-core-v2): publish prompt.accepted on the event bus

* test(transcript): add the contract-level e2e covering every entity the client renders from

* fix(transcript): guard the prompt backfill against missing services; align stream expectations with prompt.accepted on the bus

* test(agent-core-v2): re-record event stream snapshots with prompt.accepted published

* fix(transcript): settle the spawned agent row when its lifecycle redirects to the task row

* test(transcript): move the contract e2e timeout to the describe arg (jest lint)

* fix(transcript): declare task model fields in the wire schema, carry prompt content on accepted, normalize queued content

- transcriptTaskSchema declares model/thinkingEffort: Zod strips
  undeclared keys, so schema-driven REST/WS consumers lost both fields
  the projector now populates.
- PromptAccepted carries the admitted content (it is the only event a
  first-turn prompt ever emits, and the bare id left the prompts entity
  permanently partial) — projected with userMessageId and the public
  content shape via projectPromptContentParts, same as queued and the
  live backfill.
- Regenerate the wire manifest and re-record the affected event-stream
  snapshots.

* fix(transcript): preserve task model fields across termination and accepted prompt details across queueing

- onTaskLifecycle carried resultSummary/usage/error/stateReason but
  dropped model/thinkingEffort: a completed detached-Agent row lost the
  metadata spawned set while running.
- prompt.queued rebuilt the entity from scratch, discarding the
  userMessageId and createdAt that prompt.accepted had just stamped —
  build the queued update from prev.

* fix(transcript): keep prompt.accepted out of the public v1 event stream

The observable marker made the broadcaster forward every accepted
prompt to v1 WS clients, but events-zod has no accepted variant (v1
surfaces submission through the service-synthesized prompt.submitted)
and the SDK mapper didn't drop it — schema-driven clients could reject
the frame. Drop it at the WS edge and in the SDK's dropped set; the
transcript projection keeps consuming it internally.

* fix(transcript): derive cold task-turn boundaries through undo anchor replays

* fix(transcript): flush trailing folded notifications into the open turn

* fix(transcript): drop trailing buffered notifications to match the live projector

* chore: split transcript changesets per logical change

* fix(transcript): parse only the generated Title/Severity header lines in folded notifications
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant